package com.shopping.dao;

import com.shopping.pojo.Message;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface MessageDao {

    String TABLE_NAME = "message";
    String INSERT_FIELDS = "rec_message_id, message_context";
    String SELECT_FIELDS = "rec_message_id recMessageId, message_context messageContext";

    @Insert({"insert into ", TABLE_NAME, " (", INSERT_FIELDS, ") values(#{recMessageId}, #{messageContext})"})
    int insert(Message message);

    @Select({"select ", SELECT_FIELDS, " from ", TABLE_NAME, "where rec_message_id=#{recMessageId}"})
    List<Message> selectById(@Param("recMessageId") int recMessageId);

    @Delete({"delete from ", TABLE_NAME, " where rec_message_id=#{recMessageId}"})
    int deleteAll(@Param("recMessageId") int recMessageId);

}
